home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / powerd / lib / startup_oop.ass < prev    next >
Encoding:
Text File  |  2002-10-28  |  2.1 KB  |  98 lines

  1. START    movem.l    d0/a0,-(a7)    ;save initial values
  2.     movea.l    $4.w,a6
  3.     suba.l    a1,a1
  4.     jsr    (-294,a6)        ; FindTask()
  5.     move.l    d0,a4
  6.     tst.l    (172,a4)        ; process.cli
  7.     beq.s    workbench
  8.     movem.l    (a7)+,d0/a0    ;restore regs
  9.     bra.s    cli        ;and run the user prog
  10. workbench    lea    (92,a4),a0    ; process.msgport
  11.     jsr    (-384,a6)        ;wait for a message (WaitPort(())
  12.     lea    (92,a4),a0    ; process.msgport
  13.     jsr    (-372,a6)        ;then get it (GetMsg())
  14.     move.l    d0,_wbmessage        ;save it for later reply
  15.     movem.l    (a7)+,d0/a0    ;restore
  16. cli    bsr.s    _START        ;call our program
  17.     move.l    d0,-(a7)        ;save it
  18.     tst.l    _wbmessage
  19.     beq.s    exittodos        ;if I was a CLI
  20.     jsr    (-132,a6)        ; Forbid()
  21.     move.l    (_wbmessage,pc),a1
  22.     jsr    (-138,a6)        ; Permit()
  23. exittodos    move.l    (a7)+,d0        ;exit code
  24.     rts
  25.  
  26. _START    move.l    a0,_arg
  27.     clr.b    (-1,a0,d0.w)
  28.     movea.l    $4.w,a6
  29.     lea    (DOSName,pc),a1
  30.     moveq    #37,d0
  31.     jsr    (-552,a6)        ; OpenLibrary()
  32.     move.l    d0,_DOSBase
  33.     beq.s    .FINISH
  34.  
  35.     movea.l    d0,a6
  36.     jsr    (-60,a6)        ; Output()
  37.     move.l    d0,_stdout
  38.     jsr    (-54,a6)        ; Input()
  39.     move.l    d0,_stdin
  40.  
  41.     movea.l    $4.w,a6
  42.     lea    (IntName,pc),a1
  43.     moveq    #37,d0
  44.     jsr    (-552,a6)        ; OpenLibrary()
  45.     move.l    d0,_IntuitionBase
  46.     beq.s    .CLOSEDOS
  47.  
  48.     lea    (GfxName,pc),a1
  49.     moveq    #37,d0
  50.     jsr    (-552,a6)        ; OpenLibrary()
  51.     move.l    d0,_GfxBase
  52.     beq.s    .CLOSEINT
  53.  
  54.     lea    (OOPName,pc),a1
  55.     moveq    #0,d0
  56.     jsr    (-552,a6)        ; OpenLibrary()
  57.     move.l    d0,_OOPBase
  58.     beq.s    .CLOSEGFX
  59.  
  60.  
  61.     xref    _main
  62.     jsr    _main        ; a6 is stored
  63.     move.l    d0,d2
  64.  
  65.     movea.l    _OOPBase,a1
  66.     jsr    (-414,a6)        ; CloseLibrary()
  67. .CLOSEGFX    movea.l    _GfxBase,a1
  68.     jsr    (-414,a6)        ; CloseLibrary()
  69. .CLOSEINT    movea.l    _IntuitionBase,a1
  70.     jsr    (-414,a6)        ; CloseLibrary()
  71. .CLOSEDOS    movea.l    _DOSBase,a1
  72.     jsr    (-414,a6)        ; CloseLibrary()
  73. .FINISH    move.l    d2,d0
  74.     rts
  75. ****************************************
  76.     xdef    _DOSBase
  77.     xdef    _IntuitionBase
  78.     xdef    _GfxBase
  79.     xdef    _OOPBase
  80.     xdef    _arg
  81.     xdef    _stdout
  82.     xdef    _stdin
  83.     xdef    _wbmessage
  84. ****************************************
  85. _DOSBase        dc.l    0
  86. _IntuitionBase    dc.l    0
  87. _GfxBase        dc.l    0
  88. _OOPBase        dc.l    0
  89. _arg        dc.l    0
  90. _stdout        dc.l    0
  91. _stdin        dc.l    0
  92. _wbmessage    dc.l    0
  93. ****************************************
  94. DOSName    dc.b    'dos.library',0
  95. IntName    dc.b    'intuition.library',0
  96. GfxName    dc.b    'graphics.library',0
  97. OOPName    dc.b    'oop.library',0
  98.